from ChartReport.Report import Report
import matplotlib.pyplot as plt
import pandas as pd

fig1, ax = plt.subplots()
X = 'a b c d e'.split(' ')
height = [5, 20, 15, 25, 5]
bars = ax.bar(X, height, width=0.6)

df = pd.DataFrame(
    {
        'col1': 'a b c d'.split(),
        'col2': [1, 2, 3, 4]
    }
)

fig2, axes = plt.subplots(ncols=2)
X = 'a b c d e'.split(' ')
height = [5, 20, 15, 25, 5]
axes[0].bar(X, height, width=0.6)
axes[1].bar(X, height, width=0.6)


(
    Report()
    .add_md('# matplotlib 和 pd 输出')
    .add_row(fig1, df) #把mpl的画布与dataframe 输出到同一行
    .add_row(fig2)
    .to_html('result.html')
)